package Test;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @author Alger
 * @date 2021/8/18  16:15
 * 计算一年有多少天
 */
public class Test3 {
    public static void main(String[] args) {
        System.out.println(dayNum(2020));
        Date date = new Date();
        

    }
    public static int dayNum(int year){
        if(year==0){
            return LocalDate.now().lengthOfYear();
        }else{
            return LocalDate.of(year,1,1).lengthOfYear();
        }
    }
    public static List<Date> getIntervalTimeList(Date start, Date end){
        List<Date> list = new ArrayList<>();
        while(start.getTime()<= end.getTime()){
            list.add(start);
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(start);
            calendar.add(calendar.DATE,1);
            start = calendar.getTime();
        }
        return list;
    }
}
